﻿using System;
using System.Text;

namespace U.Comm.IO
{
    public class File
    {
        /// <summary>
        /// 检查文件是否存在
        /// </summary>
        /// <param name="path">文件地址</param>
        /// <returns></returns>
        public bool CheckFile(string path)
        {
            if (path.Length < 1)
                return false;
            var shortName = path.Substring(path.LastIndexOf("\\") + 1);
            return System.IO.File.Exists(shortName);
        }
        /// <summary>
        /// 检查文件夹是否存在
        /// </summary>
        /// <param name="path">文件夹地址</param>
        /// <returns></returns>
        public bool CheckFolder(string path)
        {
            if (path.Length < 1)
                return false;
            var folderName = path.Substring(path.LastIndexOf("\\") + 1);
            return System.IO.Directory.Exists(folderName);
        }
        /// <summary>
        /// 获取指定文件夹下的所有文件和子文件夹 
        /// </summary>
        /// <param name="path">路径</param>
        /// <returns></returns>
        public string[] GetFileList(string path)
        {
            var myFoldersFiles = System.IO.Directory.GetFileSystemEntries(path);
            return myFoldersFiles;
        }
    }
}
